﻿using Ags.MonsterTools.Common;
using Ags.Mvvm;
using Microsoft.Practices.Prism.Commands;
using System.Reflection;

namespace Ags.MonsterTools
{
    public class AboutWindowViewModel : ViewModelBase<AboutWindowViewModel>
    {
        private readonly IViewManager _vm;

        public AboutWindowViewModel(IViewManager vm)
        {
            _vm = vm;
            CloseWindowCommand = new DelegateCommand<object>(ExecuteCloseWindowCommand);
            PresetAboutInfos();
        }

        private void PresetAboutInfos()
        {
            var info = new AssemblyInfo(Assembly.GetEntryAssembly());
            this.Copyright = info.Copyright;
            this.Title = info.ProductTitle;
            this.Desc = info.Description;
            this.Version = info.Version;
        }

        private string _version;

        public string Version
        {
            get { return _version; }
            set
            {
                _version = value;
                OnPropertyChanged(m => m.Version);
            }
        }


        private string _copyright;
        public string Copyright
        {
            get { return _copyright; }
            set
            {
                _copyright = value;
                OnPropertyChanged(m => m.Copyright);
            }
        }

        private string _title;
        public string Title
        {
            get { return _title; }
            set
            {
                _title = value;
                OnPropertyChanged(m => m.Title);
            }
        }

        private string _desc;
        public string Desc
        {
            get { return _desc; }
            set
            {
                _desc = value;
                OnPropertyChanged(m => m.Desc);
            }
        }

        public DelegateCommand<object> CloseWindowCommand { get; private set; }

        void ExecuteCloseWindowCommand(object view)
        {
            _vm.RemoveView(view, RegionConstants.WINDOWREGION);
        }
    }
}
